package com.zhonghui.wms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zhonghui.response.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.wms.domain.WmsCargoOwner;
import com.zhonghui.wms.service.IWmsCargoOwnerService;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.common.core.page.TableDataInfo;

/**
 * 智能仓储WMS-基础数据-货主Controller
 *
 * @author zhonghui
 * @date 2022-06-04
 */
@Api(tags="智能仓储WMS-基础数据-货主")
@RestController
@RequestMapping("/wms/cargoOwner")
public class WmsCargoOwnerController extends BaseController
{
    @Autowired
    private IWmsCargoOwnerService wmsCargoOwnerService;

    /**
     * 查询智能仓储WMS-基础数据-货主列表
     */
    @ApiOperation("查询智能仓储WMS-基础数据-货主列表")
    @GetMapping("/list")
    public TableDataInfo<List<WmsCargoOwner>> list(WmsCargoOwner wmsCargoOwner)
    {
        startPage();
        List<WmsCargoOwner> list = wmsCargoOwnerService.selectWmsCargoOwnerList(wmsCargoOwner);
        return getDataTable(list);
    }

    /**
     * 导出智能仓储WMS-基础数据-货主列表
     */
    @ApiOperation("导出智能仓储WMS-基础数据-货主列表")
    @Log(title = "智能仓储WMS-基础数据-货主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsCargoOwner wmsCargoOwner)
    {
        List<WmsCargoOwner> list = wmsCargoOwnerService.selectWmsCargoOwnerList(wmsCargoOwner);
        ExcelUtil<WmsCargoOwner> util = new ExcelUtil<WmsCargoOwner>(WmsCargoOwner.class);
        util.exportExcel(response, list, "智能仓储WMS-基础数据-货主数据");
    }

    /**
     * 获取智能仓储WMS-基础数据-货主详细信息
     */
    @ApiOperation("获取智能仓储WMS-基础数据-货主详细信息")
    @GetMapping(value = "/{id}")
    public BaseResult<WmsCargoOwner> getInfo(@PathVariable("id") Long id)
    {
        return BaseResult.success(wmsCargoOwnerService.selectWmsCargoOwnerById(id));
    }

    /**
     * 新增智能仓储WMS-基础数据-货主
     */
    @ApiOperation("新增智能仓储WMS-基础数据-货主")
    @Log(title = "智能仓储WMS-基础数据-货主", businessType = BusinessType.INSERT)
    @PostMapping
    public BaseResult<Integer> add(@RequestBody WmsCargoOwner wmsCargoOwner)
    {
        return BaseResult.success(wmsCargoOwnerService.insertWmsCargoOwner(wmsCargoOwner));
    }

    /**
     * 修改智能仓储WMS-基础数据-货主
     */
    @ApiOperation("修改智能仓储WMS-基础数据-货主")
    @Log(title = "智能仓储WMS-基础数据-货主", businessType = BusinessType.UPDATE)
    @PutMapping
    public BaseResult<Integer> edit(@RequestBody WmsCargoOwner wmsCargoOwner)
    {
        return BaseResult.success(wmsCargoOwnerService.updateWmsCargoOwner(wmsCargoOwner));
    }

    /**
     * 删除智能仓储WMS-基础数据-货主
     */
    @ApiOperation("删除智能仓储WMS-基础数据-货主")
    @Log(title = "智能仓储WMS-基础数据-货主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public BaseResult<Integer> remove(@PathVariable Long[] ids)
    {
        return BaseResult.success(wmsCargoOwnerService.deleteWmsCargoOwnerByIds(ids));
    }
}
